<template>
  <div>
    <Card class="mt_10">
      <div class="point-data" style="margin-top: -5px">
        <Table
          :loading="loading"
          border
          :columns="pointsColumns"
          :data="pointData"
          class="mt_10"
          ref="table"
        >
        </Table>
        <Row type="flex" justify="end" class="mt_10" style="margin-top: 10px">
          <Page
            :current="pointSearchForm.pageNumber"
            :total="pointTotal"
            :page-size="pointSearchForm.pageSize"
            @on-change="pointChangePage"
            @on-page-size-change="pointChangePageSize"
            :page-size-opts="[10, 20, 50, 100]"
            size="small"
            show-total
            show-elevator
            show-sizer
          ></Page>
        </Row>
      </div>
    </Card>
  </div>
</template>

<script>
import * as API_Memberlist from "@/api/partner.js";

export default {
  name: "memberDetail",
  components: {},
  data() {
    return {
      id: "", //会员id
      loading: true, // 表单加载状态
      //推广会员表格列
      pointsColumns: [
        {
          title: "用户名",
          key: "username",
          tooltip: true,
        },
        {
          title: "昵称",
          key: "nickName",
          tooltip: true,
        },
        {
          title: "商家头像",
          key: "face",
          align: "left",
          render: (h, params) => {
            return h("img", {
              attrs: {
                src: params.row.face || "",
                alt: "加载图片失败",
              },
              style: {
                cursor: "pointer",
                width: "80px",
                height: "60px",
                margin: "10px 0",
                "object-fit": "contain",
              },
            });
          },
        },
        {
          title: "联系方式",
          key: "mobile",
        },
        {
          title: "加入时间",
          key: "createTime",
        },
      ],
      pointData: [], //推广会员列表
      pointTotal: 0, //分页总条数
      //历史积分数据查询form
      pointSearchForm: {
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
      },
    };
  },
  methods: {
    //查询商家
    getPointData() {
      this.loading = true;
      // let userId=this.id
      let userInfo = JSON.parse(this.getStore("userInfo"));
      console.log(userInfo, 111111111);
      let param = {
        memberId: userInfo.memberId,
        // memberId: "1498551576228438018",
        ...this.pointSearchForm,
      };
      API_Memberlist.getHistoryPointData(param).then((res) => {
        this.loading = false;
        if (res.success) {
          this.pointData = res.result.records;
          this.pointTotal = res.result.total;
        }
      });
      this.loading = false;
    },
    //记录页数变化
    pointChangePage(v) {
      this.pointSearchForm.pageNumber = v;
      this.getPointData();
    },
    //记录页数变化
    pointChangePageSize(v) {
      this.pointSearchForm.pageNumber = 1;
      this.pointSearchForm.pageSize = v;
      this.getPointData();
    },
  },

  mounted() {
    this.getPointData();
  },
};
</script>
<style lang="scss" scoped>
.head-title {
  font-size: 18px;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 400;
}
.detail-body {
  margin-top: 17px;
}

.head-info {
  display: flex;
  height: 100px;
  background: #f56c1d;
  padding: 12px;
  border-radius: 4px;
  align-items: center;
}

.ant-layout,
.ant-layout * {
  box-sizing: border-box;
}

.base-info {
  background-color: #fff;
  padding: 20px;
  margin-bottom: 12px;
  height: 250px;
}

.ant-col-md-6 {
  display: block;
  box-sizing: border-box;
  width: 25%;
  float: left;
}
.info-2 {
  float: left;
}

.ant-row {
  position: relative;
  height: auto;
  margin-right: 0;
  margin-left: 0;
  zoom: 1;
  display: block;
  box-sizing: border-box;
}
.bottom-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  margin-top: 6px;
  height: 36px;
  background: #f5f5f5;
  border-radius: 4px;
}

.ant-layout * {
  box-sizing: border-box;
}
.name {
  margin-left: 10px;
  color: #fff;
  font-size: 18px;
}
.phone {
  margin-left: 20px;
  font-size: 14px;
  color: #fff;
}
.item {
  display: flex;
  align-items: flex-start;
  line-height: 20px;
  margin-bottom: 2px;
}

.label {
  flex-basis: 130px;
  text-align: right;
  color: rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.info {
  font-weight: 500;
  padding-left: 0;
  margin-bottom: 0;
  width: 100%;
}

.pointsTitle {
  background-color: #fafafa;
  padding: 15px 20px;
  display: flex;
  font-size: 16px;
  line-height: 1.8;
  flex-direction: row;
  justify-content: space-around;
  color: #333;
  text-align: center;
  margin-bottom: 16px;
  .points-top-title {
    font-size: 14px;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.4);
    line-height: 14px;
    margin-bottom: 8px;
  }
  .points-top-text {
    font-size: 16px;
    font-weight: 500;
    color: #f56c1d;
    line-height: 16px;
  }
}
</style>
